package com.ims.service.impl;

import com.ims.dao.DaoSupport;
import com.ims.entity.Page;
import com.ims.entity.system.Student;
import com.ims.service.StudentMapper;
import com.ims.util.PageData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Service
public class StudentServiceImpl implements StudentMapper{

    @Resource(name = "daoSupport")
    private DaoSupport dao;





    @Override
    public int deleteByPrimaryKey(Integer sId) {
        return 0;
    }

    @Override
    public int insert(Student record) {
        return 0;
    }

    @Override
    public int insertSelective(Student record) {
        return 0;
    }

    @Override
    public Student selectByPrimaryKey(Integer sId) {
        return null;
    }

    @Override
    public int updateByPrimaryKeySelective(Student record) {
        return 0;
    }

    @Override
    public int updateByPrimaryKey(Student record) {
        return 0;
    }

    @Override
    public List<PageData> listAllStudentScore(Page page) throws Exception {
        return (List<PageData>)dao.findForList("StudentMapper.listAllStudentScore",page);


    }

    @Override
    public PageData selectBySid(Integer sId) throws Exception{

        List<PageData> list=(List<PageData>)dao.findForList("StudentMapper.listAllStudentScore",new Page());

        for (PageData p:list) {
            if ((Integer) (p.getMap().get("S_ID")) == sId) {
                return p;
            }
        }

        return null;
    }

    @Override
    public int updateScoreBySid(Student student) throws Exception{

        return (Integer) dao.update("StudentMapper.updateScoreBySid",student);

    }


}
